package com.lss.study.algorithm.niuke;

import java.util.Scanner;

/**
 * 功能描述：
 *
 * @Date: 2022/2/19 18:21
 */
public class T5 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()) {
            String s = scanner.nextLine();
            handle(s);
        }
    }

    private static void handle(String s) {
        char[] chars = s.toCharArray();
        int result = 0;
        int num;
        for (int i = chars.length - 1; i > 1; i--) {
            if (Character.isLetter(chars[i])) {
                num = 10 + chars[i] - 'A';
            } else {
                num = Character.getNumericValue(chars[i]);
            }
            result += num * Math.pow(16, chars.length - i - 1);
        }
        System.out.println(result);
    }
}
